/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entidades;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author ccedeno
 */
@Entity
@Table(name = "acc_doc", catalog = "emilima_tradoc", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "AccDoc.findAll", query = "SELECT a FROM AccDoc a"),
    @NamedQuery(name = "AccDoc.findByIdAccDoc", query = "SELECT a FROM AccDoc a WHERE a.idAccDoc = :idAccDoc"),
    @NamedQuery(name = "AccDoc.findByNombre", query = "SELECT a FROM AccDoc a WHERE a.nombre = :nombre"),
    @NamedQuery(name = "AccDoc.findByDescripcion", query = "SELECT a FROM AccDoc a WHERE a.descripcion = :descripcion")})
public class AccDoc implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 2)
    @Column(name = "id_acc_doc", nullable = false, length = 2)
    private String idAccDoc;
    @Size(max = 45)
    @Column(name = "nombre", length = 45)
    private String nombre;
    @Size(max = 45)
    @Column(name = "descripcion", length = 45)
    private String descripcion;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "accDoc", fetch = FetchType.LAZY)
    private List<DetAccMov> detAccMovList;
    @JoinColumn(name = "fk_estado", referencedColumnName = "id_estado", nullable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Estado estado;

    public AccDoc() {
    }

    public AccDoc(String idAccDoc) {
        this.idAccDoc = idAccDoc;
    }
public AccDoc(String idAccDoc, String nombre) {
        this.idAccDoc = idAccDoc;
        this.nombre = nombre;
    }

    public String getIdAccDoc() {
        return idAccDoc;
    }

    public void setIdAccDoc(String idAccDoc) {
        this.idAccDoc = idAccDoc;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }

    @XmlTransient
    public List<DetAccMov> getDetAccMovList() {
        return detAccMovList;
    }

    public void setDetAccMovList(List<DetAccMov> detAccMovList) {
        this.detAccMovList = detAccMovList;
    }

    public Estado getEstado() {
        return estado;
    }

    public void setEstado(Estado estado) {
        this.estado = estado;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idAccDoc != null ? idAccDoc.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof AccDoc)) {
            return false;
        }
        AccDoc other = (AccDoc) object;
        if ((this.idAccDoc == null && other.idAccDoc != null) || (this.idAccDoc != null && !this.idAccDoc.equals(other.idAccDoc))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
      //  return "Entidades.AccDoc[ idAccDoc=" + idAccDoc + " ]";
          return idAccDoc + " "+nombre;
    }
}
